home *** CD-ROM | disk | FTP | other *** search
Wrap
(*^ ::[paletteColors = 128; showRuler; currentKernel; fontset = title, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, L1, e8, 28, "Times"; ; fontset = subtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, L1, e6, 22, "Times"; ; fontset = subsubtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, L1, e6, 16, "Times"; ; fontset = section, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, grayBox, M22, L1, a20, 22, "Times"; ; fontset = subsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, blackBox, M19, L1, a15, 16, "Times"; ; fontset = subsubsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, whiteBox, M18, L1, a12, 14, "Times"; ; fontset = text, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 14, "Times"; ; fontset = smalltext, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = input, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeInput, M42, N23, L1, 14, "Courier"; ; fontset = output, output, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, 14, "Courier"; ; fontset = message, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L1, 14, "Courier"; ; fontset = print, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L1, 14, "Courier"; ; fontset = info, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L1, 14, "Courier"; ; fontset = postscript, PostScript, formatAsPostScript, output, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeGraphics, M7, l34, w273, h277, L1, 14, "Courier"; ; fontset = name, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = header, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 14, "Times"; ; fontset = Left Header, inactive, nohscroll, preserveAspect, L1, 14, "Times"; ; fontset = footer, inactive, nohscroll, noKeepOnOnePage, preserveAspect, center, M7, L1, 14, "Times"; ; fontset = Left Footer, inactive, nohscroll, preserveAspect, center, L1, 14, "Times"; ; fontset = help, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = clipboard, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 14, "Times"; ; fontset = completions, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 14, "Courier"; ; fontset = special1, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 14, "Times"; ; fontset = special2, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 14, "Times"; ; fontset = special3, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 14, "Times"; ; fontset = special4, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 14, "Times"; ; fontset = special5, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 14, "Times"; ;] :[font = title; inactive; preserveAspect; rightWrapOffset = 531; fontColorBlue = 65535; ] COSY_PAK Control Systems Analysis Package for Mathematica ;[s] 2:0,0;49,1;61,-1; 2:1,25,19,Times,1,28,0,0,65535;1,26,20,Times,3,28,0,0,65535; :[font = subtitle; inactive; preserveAspect; rightWrapOffset = 531; ] By C.K. Chen N. Sreenath 1992 :[font = message; inactive; preserveAspect; center; rightWrapOffset = 531; fontName = "Courier"; ] Systems Engineering Department Case School of Engineering Case Western Reserve University Cleveland, OH, 44106-7070 :[font = message; inactive; dontPreserveAspect; center; rightWrapOffset = 531; ] Support from CWRU Information and Network Services - Dr. Ray Neff Case Alumni Association The Lilly Foundation :[font = input; preserveAspect; rightWrapOffset = 531; ] :[font = subtitle; inactive; preserveAspect; rightWrapOffset = 531; ] Chapter 2 Mathematical Modeling of Dynamic Systems ;[s] 4:0,0;10,1;11,2;51,3;53,-1; 4:1,20,15,Times,1,22,65535,0,0;1,20,15,Times,1,22,0,0,0;1,20,15,Times,1,22,0,0,65535;1,16,12,Times,1,18,0,0,0; :[font = section; inactive; Cclosed; preserveAspect; rightWrapOffset = 531; startGroup; ] Initialization :[font = input; initialization; preserveAspect; rightWrapOffset = 531; ] *) (* Initialization of Path *) (* Example For UNIX machine (Default) *) $Path=Join[$Path, {"~/Library/Mathematica/Packages"}]; (* Example For IBM PC *) (* $Path=Join[$Path, {"c:\winmath\packages"}]; *) (* Example For MAC *) (* $Path=Join[$Path, {"My_Harddisk:Mathematica:Package"}]; *) (* :[font = input; initialization; preserveAspect; rightWrapOffset = 531; endGroup; ] *) Needs["COSYPAK`chap2`"] (* :[font = section; inactive; Cclosed; preserveAspect; rightWrapOffset = 531; startGroup; ] Acknowledgements :[font = text; inactive; preserveAspect; rightWrapOffset = 531; endGroup; ] Special thanks to Brian Evans of Georgia Tech for the LaPlace transform and signal packages which is a part of the Signal Processing Packages :Copyright: Copyright 1989-1991 by Brian L. Evans, Georgia Tech Research Corporation. :[font = section; inactive; Cclosed; preserveAspect; rightWrapOffset = 531; startGroup; ] ODE to State Space :[font = text; inactive; preserveAspect; rightWrapOffset = 531; ] Note: Due to the lack of subscripts and superscripts in the Macintosh version of Mathematica, subscripts and superscripts will be represented with numbers located immediately after the variable. If the subscript involves a function then the funcion will be in parenthesis immediately following the variable. Dervatives, on the other hand, will always use parenthesis, for example, y(2) represents the second derivative of the function y. An nth order Ordinary Differential Equation (ODE) of the form: y(n) + a1 y(n-1) + ... + a(n-1) y(1) + a(n) y = b0 u(n) + b1 u(n-1) + ... + b(n) u can be represented by a first-order vector matrix differential equation: x(1) = Ax + Bu y = Cx + Du where x1 0 1 0 . . . 0 x2 0 0 1 . . . 0 . . x = . A = . . . xn-1 0 0 0 . . . 1 xn -an -an-1 -an-2 . . . -a1 B1 B2 C = [ 1 0 . . . 0 ] . B = . . Bn-1 D = b0 Bn with B0 = b0 B1 = b1 - a1B0 B2 = b2 - a1B1 - a2B0 . . . Bn = bn - a1Bn-1 - . . . - an-1B1 - anb0. COSY_PAK Function Ode2SS[lhscoeff, rhscoeff]: Converts linear ordinary differential equation (ODE) to state space eqn. The ODE is in the format: y(n) + a1 y(n-1) + ... + an-1 y(1) + an y = b0 u(n) + b1 u(n-1) + ... bn-1 u(1) + bn u where lhscoeff = [1, a1,...,an], rhscoeff = [b0,b1,...,bn]. If ai or bi don't exist, use ai=0 or bi=0. The output are Matrix A and Vector B in the state equation: dx/dt = A x + B u. Returns the state space matrices A and B as {A,B}. ;[s] 15:0,0;385,1;388,2;456,3;486,4;509,5;512,6;1275,7;1292,8;1293,9;1320,10;1521,11;1529,12;1549,13;1558,14;1749,-1; 15:1,13,10,Times,0,14,0,0,0;1,13,10,Times,32,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,12,9,Times,1,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,13,10,Times,32,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,12,9,Times,1,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,12,9,Times,1,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,12,9,Times,1,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,12,9,Times,1,14,0,0,0;1,13,10,Times,0,14,0,0,0; :[font = subsubsection; inactive; Cclosed; preserveAspect; rightWrapOffset = 531; startGroup; ] Example :[font = input; preserveAspect; rightWrapOffset = 531; startGroup; ] lcoeff = {1,a1,a2,a3}; rcoeff = {b2,b3}; results = Ode2SS[rcoeff,lcoeff]; :[font = print; inactive; dontPreserveAspect; rightWrapOffset = 531; endGroup; endGroup; endGroup; ] The A Matrix is: 0 1 0 0 0 1 -a3 -a2 -a1 The B Vector is: 0 b2 -(a1 b2) + b3 :[font = section; inactive; Cclosed; preserveAspect; rightWrapOffset = 531; startGroup; ] Linearization of a Nonlinear System of Equations :[font = text; inactive; preserveAspect; rightWrapOffset = 531; ] Many systems are nonlinear but operate around a set point which my also be referred to as a nominal point or an operating point. Using a process called linearization, a nonlinear system may be analyzed by linear methods. One method of linearization involves the expansion of a nonlinear function about its set point into a Taylor series. The higher terms of the expansion are dropped leaving only the linear term. :[font = text; inactive; preserveAspect; rightWrapOffset = 531; ] The nonlinear system y = f(x) can be expanded about an operating point x*,y* with derivatives evaluated at x = x*: y = f(x) | x =x * + f(1)(x) | x =x* (x - x*) + (1/2!)f(2)(x) | x =x* (x - x*)2 + . . . The nonlinear higer order terms may be dropped if the magnitude of x - x* is small. This gives the above equation the form y = y* + K(x - x*) with y* = f(x*) and K = f(1)(x) | x = x*. ;[s] 16:0,0;131,1;138,2;141,3;144,4;150,5;156,6;174,7;177,8;183,9;189,10;197,11;198,12;385,13;388,14;394,15;404,-1; 16:1,13,10,Times,0,14,0,0,0;1,13,10,Times,64,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,13,10,Times,32,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,13,10,Times,64,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,13,10,Times,32,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,13,10,Times,64,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,13,10,Times,32,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,13,10,Times,32,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,9,7,Times,64,10,0,0,0; :[font = text; inactive; preserveAspect; rightWrapOffset = 531; ] For a system of nonlinear equations with z a vector of states, v an input, and w an output with z(1) = f(z,v) w = h(z,v). If Dz = x Dv = u Dw = y then the linearization process can be applied to yield x(1) = Ax + Bu y = Cx + Du where f(1) = df/dz | z = z*. ;[s] 11:0,0;129,1;130,2;136,3;137,4;143,5;144,6;250,7;251,8;253,9;254,10;267,-1; 11:1,13,10,Times,0,14,0,0,0;1,0,0,Symbol,0,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,0,0,Symbol,0,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,0,0,Symbol,0,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,0,0,Symbol,0,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,0,0,Symbol,0,14,0,0,0;1,11,8,Times,0,12,0,0,0; :[font = text; inactive; preserveAspect; rightWrapOffset = 531; ] COSY_PAK Function Linearize[ f , zvars , zpoint , vvars , vpoint]: Gives the linearization of vector function f[zvars, vvars] = {f1[zvars, vvars], ... ,fn[zvars, vvars]} around the operating point zpoint and vpoint. The length of the state variables zvars = [x1,...,xn] must be equal to the length of the operating point zpoint = [x10,...,xn0] and the length of the control variables vvars = [v1,...,vr] must be equal to the length of the operating point vpoint = [v10,...,vr0]. Returns the linearized system matrices A and B as {A,B}. ;[s] 21:0,0;17,1;18,2;65,3;110,4;169,5;251,6;271,7;322,8;344,9;385,10;404,11;456,12;479,13;519,14;520,15;525,16;526,17;531,18;536,19;537,20;539,-1; 21:1,12,9,Times,1,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,12,9,Times,1,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,12,9,Times,1,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,12,9,Times,1,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,12,9,Times,1,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,12,9,Times,1,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,12,9,Times,1,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,12,9,Times,1,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,12,9,Times,1,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,12,9,Times,1,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,11,8,Times,0,12,0,0,0; :[font = subsubsection; inactive; Cclosed; preserveAspect; rightWrapOffset = 531; startGroup; ] Example :[font = input; preserveAspect; rightWrapOffset = 531; startGroup; ] f={z1^2 z2 -Sin[z2]+v^3,z1 Cos[z2] + v}; zvars={z1,z2}; vvars={v}; zpoint={1,2};vpoint = {1}; results = Linearize[f,zvars,zpoint,vvars,vpoint]; (* Matrix A is in results[[1]], vector B is in results[[2]] *) :[font = print; inactive; dontPreserveAspect; rightWrapOffset = 531; endGroup; endGroup; endGroup; ] The A Matrix is: 4 1 - Cos[2] Cos[2] -Sin[2] The B Vector is: 3 1 :[font = section; inactive; Cclosed; preserveAspect; rightWrapOffset = 531; startGroup; ] State Space to Transfer Function :[font = text; inactive; preserveAspect; rightWrapOffset = 531; ] COSY_PAK Function SS2Transf[A,B,C,s]: This function transforms the state space representation of system (A, B, C) to its transfer function representation. Returns the transfer function transf as a function of the Laplace variable `s'. ;[s] 7:0,0;36,1;105,2;114,3;186,4;193,5;230,6;236,-1; 7:1,12,9,Times,1,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,12,9,Times,1,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,12,9,Times,1,14,0,0,0;1,13,10,Times,0,14,0,0,0;1,12,9,Times,1,14,0,0,0; :[font = input; dontPreserveAspect; leftWrapOffset = 20; rightWrapOffset = 531; startGroup; ] AA={{0,1,0,0},{0,0,1,0},{0,0,0,1},{-a1,-a2,-a3,-a4}}; BB={0,0,0,1}; CC={1,0,0,0}; results = SS2Transf[AA,BB,CC,s]; (* The transfer function is in 'results' *) :[font = print; inactive; preserveAspect; rightWrapOffset = 531; endGroup; endGroup; ] 1 The transfer function is:------------------------------ 2 3 4 a1 + a2 s + a3 s + a4 s + s ^*)